package LeetCode.leetcode101;

public class Review2 {
    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;
        return isMirror(root.left, root.right);
    }
    public boolean isMirror(TreeNode left, TreeNode right) {
        if (left == null && right == null) return true;
        if (left == null || right == null) return false;
        if (left.val != right.val) return false;
        boolean leftMirror = isMirror(left.left, right.right);
        boolean rightMirror = isMirror(left.right, right.left);
        return leftMirror && rightMirror;
    }
}
